package com.tywj.panda.driver.tool

import android.app.ActivityManager
import android.content.Context
import android.util.Log
import com.tywj.lib.core.common.util.LogUtil

/**
 * <pre>
 *     author : June Yang
 *     time   : 2020/7/15
 *     desc   : 判断后台是否进行
 *     version: 2.0.0
 * </pre>
 */
object ServiceTool {
    fun isWorked(context: Context, serviceName: String): Boolean {
        val manager = context.applicationContext.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager

        val runningService = manager.getRunningServices(30)

        runningService.forEach {
            LogUtil.d("service=="+it.service.className)
            if (it.service.className == serviceName) {
                return true
            }
        }
        return false
    }

}